<template>
  <div class="search-result">
    <van-list
      v-model='loading'
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <van-cell v-for="(item , index) in searchList" :key="index" :title="item.title" />
    </van-list>
  </div>
</template>

<script>
import { searchResult } from '@/api/search'
export default {
  props:  {
    value: {
      type : String,
      default: () => {
        return ''
      },
    },
  },

  data() {
    return {
      page: 0,
      per_page: 10,
      searchList : [],
      finished : false , // 是否已加载完成，加载完成后不再触发load事件,
      loading : false  //  是否加载
    }
  },
  methods: {
    async getSearchResult() {
      const { data: res } = await searchResult({
        page: ++this.page,
        per_page: this.per_page,
        q: this.historyItem || this.value,
      })

      console.log(res, 5555)
      this.searchList = [...this.searchList , ...res.data.results]
      this.loading = false

      if( res.data.results.length){
 
      }else{
        this.finished = true
      }
    },
    onLoad(){
        this.getSearchResult()
    }
  },
  created() {
   
  },
}
</script>

<style scoped lang='less'>

</style>